package com.example.hospital.patient.wx.api.service.impl;

import com.example.hospital.patient.wx.api.service.PaymentService;
import org.springframework.stereotype.Service;

import static com.example.hospital.patient.wx.api.utils.RandomStringUtil.generateRandomString;

import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;

@Service
public class PaymentServiceImpl implements PaymentService{

    @Override
    public Map unifiedOrder(String outTradeNo, String openId, int total, String desc) {
        Map paymentNode = new HashMap();
        Calendar cal = Calendar.getInstance();
        String year = String.valueOf(cal.get(Calendar.YEAR));
        System.out.println(year);
        String prepayId = generateRandomString(12, year, true, false);
        System.out.println(prepayId);
        paymentNode.put("prepayId",prepayId);
        long timestamp = System.currentTimeMillis();
        paymentNode.put("timeStamp",timestamp);
        paymentNode.put("outTradeNo",outTradeNo);
        paymentNode.put("openId",openId);
        paymentNode.put("total", total);
        paymentNode.put("desc",desc);
        return paymentNode;
    }
}
